package com.ycrlkj.android.modulespublic.common.arouter;

import android.content.Context;
import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.annotation.Interceptor;
import com.alibaba.android.arouter.facade.callback.InterceptorCallback;
import com.alibaba.android.arouter.facade.template.IInterceptor;
import com.alibaba.android.arouter.launcher.ARouter;
import com.ycrlkj.android.modulespublic.common.constant.RoutePath;

/**
 * ARouter跳转拦截器
 */
@Interceptor(priority = 1)
public class MInterceptor implements IInterceptor {
    @Override
    public void process(Postcard postcard, InterceptorCallback callback) {
        //测试写的, 检测到跳转路径是 login 就跳转到 /app/login
        //todo 实际应用中可以做跳转权限判断
        if (postcard.getPath().equals("login")){
            ARouter.getInstance().build(RoutePath.PAGE_LOGIN).navigation();
        }else {
            callback.onContinue(postcard);
        }
    }

    @Override
    public void init(Context context) {}
}